package com.sh.caryr.erp.entity.enums;

import com.baomidou.mybatisplus.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

import java.io.Serializable;
import java.util.Arrays;

public enum SkuStatus implements IEnum {
    NORMAL(1,"正常"),
    WARN(2,"警戒"),
    OUT(3,"无货"),
    OVER(4,"超卖");

    private final int value;
    private final String desc;

    SkuStatus(final int value, final String desc) {
        this.value = value;
        this.desc = desc;

    }

    @JsonValue
    @Override
    public Serializable getValue() {
        return this.value;
    }

    public String getDesc() {
        return this.desc;
    }

    @JsonCreator
    static SkuStatus findValue(@JsonProperty("value") int value) {
        for (SkuStatus e : SkuStatus.values()) {
            if (e.getValue() == value) {
                return e;
            }
        }
        return NORMAL;
    }
}
